package com.gd.iot.energy.controller.statistics;

import com.gd.iot.energy.annotation.SystemLogRecordMonitor;
import com.gd.iot.energy.entity.ResponseEntity;
import com.gd.iot.energy.pojo.common.vo.ChartVO;
import com.gd.iot.energy.service.statistics.StatisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 统计分析-用量分析-趋势分析
 *
 * @author kris
 * @date Created at 2020/8/11 10:50
 */
@Api(value = "统计分析-用量分析-趋势分析",tags = "统计分析-用量分析-趋势分析")
@RestController
@RequestMapping("/admin/loopRatio")
public class TrendController {

    @Autowired
    private StatisticsService statisticsService;

    @ApiOperation("趋势分析图表")
    @SystemLogRecordMonitor("趋势分析图表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "beginDate", value = "起始日期", dataType = "string", paramType = "query", example = "", required = true),
            @ApiImplicitParam(name = "endDate", value = "结束日期", dataType = "string", paramType = "query", example = "", required = true),
            @ApiImplicitParam(name = "areaId", value = "区域id", dataType = "string", paramType = "query", example = "", required = false),
    })
    @PostMapping("/getTrendStatisticsChartVO")
    public ResponseEntity<List<ChartVO>> getTrendStatisticsChartVO(
            @RequestParam(value = "beginDate",required = true)String beginDate,
            @RequestParam(value = "endDate",required = true)String endDate,
            @RequestParam(value = "areaId",required = false)Integer areaId
    ) {

        List<ChartVO> chartVOS = statisticsService.getTrendStatisticsChartVO(
                beginDate,endDate,areaId);
        return new ResponseEntity<>(chartVOS);
    }
}
